<!DOCTYPE html>
<html>
<head>
<title>Insert an @viewport rule after an existing one (CSSOM)</title>
<style>
@viewport {
  width: 500px;
}
</style>
<script>
  if (window.testRunner)
    testRunner.injectStyleSheet("@viewport { width: extend-to-zoom 980px; min-zoom: 0.25; max-zoom: 5; height: auto; zoom: auto; user-zoom: zoom; orientation: auto }", true);

  function test() {
    if (window.testRunner) {
      testRunner.dumpAsText();
      document.styleSheets[0].insertRule("@viewport {width: 1000px}", 1);
      document.body.offsetWidth; // Trigger style resolving
      alert(internals.viewportAsText(document, 1, 320, 352));
    }
  }
</script>
</head>
<body onload="test()"></body>
</html>
